﻿using ActiveDirectoryService.Library.DataContracts;
using ActiveDirectoryService.Library.Entities;

namespace ActiveDirectoryService.Library.Converters
{
    public class Converter : IConverter
    {
        public ADUser Convert(User user)
        {
            return user == null ? null : new ADUser
                       {
                           Name = user.Name,
                           AccountName = user.AccountName,
                           Division = user.Division,
                           Email = user.Email,
                           Function = user.Function,
                           Office = user.Office,
                           SipAddress = user.SipAddress,
                           HideMobilePhone = user.HideMobilePhone,
                       };
        }

        public User Convert(ADUser user)
        {
            return user == null ? null : new User
            {
                Name = user.FirstName + " " + user.LastName,
                AccountName = user.AccountName,
                Division = user.Division,
                Email = user.Email,
                Function = user.Function,
                Office = user.Office,
                SipAddress = user.SipAddress,
                HideMobilePhone = user.HideMobilePhone
            };
        }

        public ADGroup Convert(Group group)
        {
            return group == null ? null : new ADGroup
            {
                Name = group.Name,
                Email = group.Email,
                DistinguishedName = group.DistinguishedName,
                AccountType = group.GroupType,
            };
        }

        public Group Convert(ADGroup group)
        {
            return group == null ? null : new Group
            {
                Name = group.Name,
                Email = group.Email,
                GroupType = group.AccountType,
                DistinguishedName = group.DistinguishedName,
            };
        }
    }
}